import { http } from "@/utils/http";
import type { TableItem } from "./type";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

//值班抄表|查询值班抄表配置
export const meterreadingqueryList = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterreading/queryList`, {
    data
  });
};

// //查询指标抄表数据（根据抄表项ID）
// export const meterreadingqueryList = (data?: object) => {
//   return http.request<ResultTable>("post", `/operation/api/v1/meterreading/queryList`, {
//     data
//   });
// };

//系统树
export const systemCategoryqueryListTree = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/systemCategory/queryListTree`, {
    data
  });
};

//值班抄表|新增值班抄表配置
export const meterreadingadd = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterreading/add`, {
    data
  });
};

//值班抄表|删除值班抄表配置
export const meterreadingdelete = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterreading/delete`, {
    data
  });
};

//值班抄表|修改值班抄表配置
export const meterreadingupdate = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterreading/update`, {
    data
  });
};

//值班抄表|查询值班抄表配置
export const meterreadingqueryById = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterreading/queryById`, {
    data
  });
};

//查询设备下的仪表
export const eqpRelqueryEqpRelByEqpId = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/eqpRel/queryEqpRelByEqpId`, {
    data
  });
};

//查询指标下的设备
export const measuregetMeasure = (data?: object) => {
  return http.request<ResultTable>("post", `/account/api/v1/measure/getMeasure`, {
    data
  });
};

//验证抄表数据
export const meterReadingRecordvalidate = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterReadingRecord/validate`, {
    data
  });
};

//修改抄表数据
export const meterReadingRecordupdate = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterReadingRecord/update`, {
    data
  });
};

//新增抄表数据
export const meterReadingRecordadd = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterReadingRecord/add`, {
    data
  });
};

//抄表数据历史记录
export const meterReadingRecordqueryAll = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/meterReadingRecord/queryAll`, {
    data
  });
};
//验证计划 上传数据
export const meterreadingimport = (data?: object | undefined, cb?: (err: any) => any) =>
  http.request<Array<TableItem>>(
    "post",
    `/operation/api/v1/meterreading/import`,
    { data },
    { headers: { noLoading: true, "Content-Type": "multipart/form-data" } },
    cb
  );
//根据仪表id查询关联的设备列表
export const eqpRelqueryByRelEqpId = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/eqpRel/queryByRelEqpId`, {
    data
  });
};
//验证计划 上传数据
export const meterReadingRecordimport = (data?: object | undefined, cb?: (err: any) => any) =>
  http.request<Array<TableItem>>(
    "post",
    `/operation/api/v1/meterReadingRecord/import`,
    { data },
    { headers: { noLoading: true, "Content-Type": "multipart/form-data" } },
    cb
  );
